@extends('app')

@section('content')
<link href="{{ asset('/css/spinners.css') }}" rel="stylesheet">

<div id="grid" class="grid" style="position: fixed;z-index: 1000;left:50%;display: none;">
    <div class="cell">
        <div class="card">
            <span class="throbber-loader">Loading…</span>
        </div>
    </div>
</div>
<ul class="nav nav-tabs">
    <li class="active"><a href="{{url('/admin/teaches/index')}}">课程列表</a></li>
     <li><a href="{{url('admin/teaches/index/create')}}">新增课程</a></li>
</ul>
<div class="panel panel-default mt20">
    <div class="panel-heading">课程信息</div>
    <div class="table-responsive panel-body">
        <div class="col-xs-12 col-sm-3 col-md-4"><img src="@if(count($chapter->teaches->attachment)>0){{$chapter->teaches->attachment->url}}@endif"></div>
        <div class="col-sm-7 col-xs-12">
            <p>课程名称：{{ $chapter->teaches->name }} &nbsp;&nbsp;&nbsp; <span>价格:{{$chapter->teaches->price}}</span></p>
            <p>阅读须知：{{ $chapter->notice }}</p>
            <p>
                <span>学习人数：{{ $chapter->teaches->studys_num }}</span>&nbsp;&nbsp;&nbsp;
                <span>浏览数：{{ $chapter->teaches->views_num }}</span>&nbsp;&nbsp;&nbsp;
                <span>评论数：{{ $chapter->teaches->comments_num }}</span>&nbsp;&nbsp;&nbsp;
                <span>收藏数：{{ $chapter->teaches->attention_num }}</span>&nbsp;&nbsp;&nbsp;
           </p>
           <p>所在章节：{{ $chapter->name }}</p>
        </div>
    </div>
</div>
<div class="mt20">
    <a href="javescript:void(0);" data-toggle="modal" data-target="#myModal1"><i class="glyphicon glyphicon-plus"></i>新增</a>
</div>
<div class="panel panel-default mt20">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
          <thead>
            <tr>
              <th>编号</th>
              <th>标题</th>
              <th>作者</th>
              <th>教程类型</th>
              <th>发布时间</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
          @foreach($courses as $res)
            <tr id="news_{{ $res->id }}">
              <td>{{ $res->id }}</td>
              <td><a href="{{ url('/admin/teaches/index/course/'.$res->id.'/edit') }}">{{ str_limit($res->name,30) }} </a></td>
              <td>{{ $res->userinfo->name }}</td>
              <td>
              @if($res->teaches_type ==1)
              视频教程
              @elseif($res->teaches_type ==2)
              OFFICE类教程
              @elseif($res->teaches_type ==3)
              PPT教程
              @else
              分布教程
              @endif
              </td>
              <td>{{ $res->updated_at}}</td>
              <td>
                <a href="{{ url('/admin/teaches/index/course/'.$res->id.'/edit') }}"><i class="glyphicon glyphicon-edit"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="javascript:void(0);" onclick="delete_one('/admin/teaches/index/course/{{$res->id}}','{{$res->id}}','{{ csrf_token() }}')"><i class="glyphicon glyphicon-remove-sign"></i></a>
             </td>
            </tr>
          @endforeach
          </tbody>
        </table>
    </div>
</div>
<div>{!! $courses->render() !!} </div>
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">选择添加文章类型</h4>
      </div>
      <div class="modal-body">
        <div class="row">
            <div class="col-md-3">
                <a href="{{ url('/admin/teaches/index/course/create?mod=ppt&chapter='.$chapter->id) }}" ><i class="glyphicon glyphicon-plus"></i>PPT教程</a>
            </div>
            <div class="col-md-3">
                <a href="{{ url('/admin/teaches/index/course/create?mod=step&chapter='.$chapter->id) }}" ><i class="glyphicon glyphicon-plus"></i>分步教程</a>
            </div>
            <div class="col-md-3">
                <a href="{{ url('/admin/teaches/index/course/create?mod=video&chapter='.$chapter->id) }}" ><i class="glyphicon glyphicon-plus"></i>视频教程</a>
            </div>
            <div class="col-md-3">
                <a href="{{ url('/admin/teaches/index/course/create?mod=office&chapter='.$chapter->id) }}" ><i class="glyphicon glyphicon-plus"></i>OFFICE教程</a>
            </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary" id="submittags" data-dismiss="modal">确定</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>  
@endsection
